package org.sky.platform.controller;

import org.sky.platform.model.UserModel;
import org.sky.platform.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@Api(value = "首页", tags = {"系统首页"})
@Controller
@RequestMapping(value = "home")
public class HomeController {
	//定义一个全局的记录器，通过LoggerFactory获取
    private final static Logger logger = LoggerFactory.getLogger(HomeController.class);

	@Autowired
	private UserService userService;
	@ApiOperation("系统首页")
	@RequestMapping(value = "index")
	public ModelAndView homeIndex() {
		System.out.println("redirect to index page!");
		UserModel um = userService.testDBSelectOne();
		ModelAndView mode = new ModelAndView();
		mode.addObject("welcome", "欢迎:"+um.getUserName());
		mode.setViewName("index/index");
		return mode;
	}

	@RequestMapping(value = "/jsp/index")
	@ResponseBody
	public ModelAndView index() {
		System.out.println("go to the home page!");
		ModelAndView mode = new ModelAndView();
		mode.addObject("name", "zhangsan");
		mode.setViewName("index");
		return mode;
	}
}